package com.qm.struts.login;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.opensymphony.xwork2.Action;
import com.qm.hibernate.Tuser;
import com.qm.hibernate.TuserDAO;

public class RegisterAction implements Action {
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getConfirm() {
		return confirm;
	}

	public void setConfirm(String confirm) {
		this.confirm = confirm;
	}

	private String username;
	private String password;
	private String email;
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	private String confirm;

	@Override
	public String execute() throws Exception {
		
		TuserDAO td = new TuserDAO();
		Tuser t = new Tuser(getEmail(),getUsername(),getPassword());
		Session session = td.getSession();  
        Transaction tx = session.beginTransaction();  
        td.save(t);
        tx.commit();  
        session.close();  
		
		// TODO Auto-generated method stub
		return SUCCESS;
	}

}
